﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Warranty_Warranty : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            WarrantyDBConnection warrantyConn = new WarrantyDBConnection();
            Warranty warranty = warrantyConn.getWarrantyById((int)Session["Warranty_ID"]);
            Session.Remove("Warranty_ID");

            txtExpire_Date.Text = warranty.expire_Date.ToString();
            txtProvider_Info.Text = warranty.provider_Info;
            txtStart_Date.Text = warranty.start_Date.ToString();
            txtWarranty_ID.Text = warranty.warranty_ID.ToString();
            txtWarranty_Status.Text = warranty.warranty_Status;

        }
    }



    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        //ComputerDBConnection computerConn = new ComputerDBConnection();
        //Computer computer = computerConn.getComputerByID(Int32.Parse(txtComputerID.Text));

        //computer.computer_Name = txtComputerName.Text;
        //computer.license = txtLicense.Text;
        //computerConn.update(computer);

        //RoomDBConnection roomConn = new RoomDBConnection();
        //Room room = roomConn.getRoomByName(ddlLocation.SelectedValue);

        //HardwareDBConnection hardwareConn = new HardwareDBConnection();
        //Hardware hardware = hardwareConn.getHardwareByID(computer.hardware_ID);
        //hardware.room_no = room.room_No;
        //hardwareConn.update(hardware);
        //txtLocation.Text = room.room_Name;
        ////hardware.person_ID_no = 


        //hardware.purchase_date = DateTime.Parse(txtPurchaseDate.Text);
        //hardware.serial = txtSerial.Text;
        //hardware.warranty_ID = Int32.Parse(txtWarrenty.Text);
        //hardware.update(hardware);

        //dbConnection.update(customer);

        setEditableFalse();
        btnUpdate.Visible = false;
        btnCancle.Visible = false;
        btnEdit.Visible = true;
        btnDelete.Visible = true;


        //txtLocation.Visible = true;
        //ddlLocation.Visible = false;
        //lbtnLocation.Visible = false;
        ////lbtnPerson.Visible = false;
    }
    protected void btnCancle_Click(object sender, EventArgs e)
    {
        setEditableFalse();
        btnUpdate.Visible = false;
        btnCancle.Visible = false;
        btnEdit.Visible = true;
        btnDelete.Visible = true;


        //txtLocation.Visible = true;
        //ddlLocation.Visible = false;
        //lbtnLocation.Visible = false;
        ////lbtnPerson.Visible = false;
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        setEditableTrue();
        btnUpdate.Visible = true;
        btnCancle.Visible = true;
        btnEdit.Visible = false;
        btnDelete.Visible = false;

        //txtLocation.Visible = false;
        //ddlLocation.Visible = true;
        //lbtnLocation.Visible = true;
        ////lbtnPerson.Visible = true;
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {


    }


    private void setEditableFalse()
    {
        //txtComputerID.ReadOnly = true;
        //txtComputerName.ReadOnly = true;
        //txtLicense.ReadOnly = true;
        //txtLocation.ReadOnly = true;
        ////txtPerson.ReadOnly = true;
        //txtPurchaseDate.ReadOnly = true;
        //txtSerial.ReadOnly = true;
        //txtWarrenty.ReadOnly = true;

        //txtComputerID.BorderStyle = BorderStyle.None;
        //txtComputerName.BorderStyle = BorderStyle.None;
        //txtLicense.BorderStyle = BorderStyle.None;
        //txtLocation.BorderStyle = BorderStyle.None;
        ////txtPerson.BorderStyle = BorderStyle.None;
        //txtPurchaseDate.BorderStyle = BorderStyle.None;
        //txtSerial.BorderStyle = BorderStyle.None;
        //txtWarrenty.BorderStyle = BorderStyle.None;
    }
    private void setEditableTrue()
    {
        //txtComputerID.ReadOnly = false;
        //txtComputerName.ReadOnly = false;
        //txtLicense.ReadOnly = false;
        //txtLocation.ReadOnly = false;
        //txtPerson.ReadOnly = false;
        //txtPurchaseDate.ReadOnly = false;
        //txtSerial.ReadOnly = false;
        //txtWarrenty.ReadOnly = false;

        //txtComputerID.BorderStyle = BorderStyle.NotSet;
        //txtComputerName.BorderStyle = BorderStyle.NotSet;
        //txtLicense.BorderStyle = BorderStyle.NotSet;
        //txtLocation.BorderStyle = BorderStyle.NotSet;
        //txtPerson.BorderStyle = BorderStyle.NotSet;
        //txtPurchaseDate.BorderStyle = BorderStyle.NotSet;
        //txtSerial.BorderStyle = BorderStyle.NotSet;
        //txtWarrenty.BorderStyle = BorderStyle.NotSet;
    }

}